﻿
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;
using GruntXProductions;
using Viper;
using Viper.Opcodes;

namespace Diamond
{
    public partial class CodeGen
    {
        public void Call(FunctionCall fc)
        {
            foreach (Expression exp in fc.Arguments)
            {
                if (GuessType(exp) == VType.Dword)
                    ParseArthemeticExpression(exp);
                else if (GuessType(exp) == VType.String)
                {
                    ParseStringExpression(exp);
                }
            }
            Assembler.Emit(new bsr(GetMethodName(fc)));
        }
		
        public void CallOperator(Operator op, OperatorOverload oo)
        {
            List<SyntaxNode> tmp = new List<SyntaxNode>();
            tmp.Add(op.Op1); tmp.Add(op.Op2);
            foreach (SyntaxNode sn in tmp)
            {
                if (GuessType(sn) == VType.Dword)
                    GetIntegerValue(sn);
                else if (GuessType(sn) == VType.String)
                    GetStringValue(sn);
				else
					Console.WriteLine("UNKOWN");
            }
            Assembler.Emit(new bsr(GetMethodName(oo)));
        }
    }

}